import React, {useContext} from 'react';
import {observer,MobXProviderContext} from 'mobx-react';
import {Button} from "antd";

/**
 * 封装mobx在子组件中使用
 * @type {IReactComponent}
 */
const MobxEncapsulationComp = observer(()=> {
    const vote = useContext(MobXProviderContext).vote;
    console.log(vote);
    return (
        <>
            <div>
                数量:{vote.num}
                <Button onClick={()=>vote.change()}>
                    +
                </Button>
            </div>
        </>
    )
})

export default MobxEncapsulationComp;